Skip to content

打开内存数据库 - OpenMemoryDatabase

函数简介

打开内存中的数据库,返回一个数据库对象指针。

接口名称

OpenMemoryDatabase

DLL调用

c
long OpenMemoryDatabase(long ola, long address, int size, string password);

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
address长整数型数据库所在的内存首地址。
size整数型数据库内存区域大小(字节)。
password字符串数据库密码。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// dbAddress 为已读入内存的数据库文件首地址
long db = ola.OpenMemoryDatabase(dbAddress, dbSize, "");
if (db != 0) {
    ola.CloseDatabase(db);
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
// dbAddress 为已读入内存的数据库文件首地址
long db = ola.OpenMemoryDatabase(dbAddress, dbSize, "");
if (db != 0)
{
    ola.CloseDatabase(db);
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
# dbAddress 为已读入内存的数据库文件首地址
db = ola.OpenMemoryDatabase(dbAddress, dbSize, "")
if db != 0:
    ola.CloseDatabase(db)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long db = ola.OpenMemoryDatabase(dbAddress, dbSize, "");
cpp
var ola = com("OlaPlug.OlaSoft")
var db = ola.OpenMemoryDatabase(dbAddress, dbSize, "")
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
db = ola.OpenMemoryDatabase(dbAddress, dbSize, "")
text
.局部变量 ola, OLAPlug
ola.创建 ()
db = ola.OpenMemoryDatabase (dbAddress, dbSize, "")
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var db = ola.OpenMemoryDatabase(dbAddress, dbSize, "");
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 db = ola.OpenMemoryDatabase(dbAddress, dbSize, "")
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long db = ola.OpenMemoryDatabase(dbAddress, dbSize, "");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long db = OpenMemoryDatabase(instance, dbAddress, dbSize, "");
if (db != 0) CloseDatabase(instance, db);
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();

long instance = CreateCOLAPlugInterFace();
long db = OpenMemoryDatabase(instance, dbAddress, dbSize, "");
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
db = ola.OpenMemoryDatabase(instance, dbAddress, dbSize, b"")

返回值

数据库对象指针。若打开失败,返回 0。

注意事项

  • addresssize 需指向包含完整数据库内容的有效内存区域。
  • 如需口令保护,确保 password 正确。
  • 使用完成后请按数据库相关接口流程进行资源释放。